package com.itheima.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/*
Stream 流的收集方法
 */
public class Demo05 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of( "鹿晗", "吴签", "吴签", "黄子韬","黄子韬","蔡徐坤"));
        //1.collect 方法需要一个Collector 接口
        //2.Collectors 提供了方法可以产生一个Collector 对象
        List<String> list2 = list.stream().filter(s -> s.length() == 3).collect(Collectors.toList());
        System.out.println(list2);
        Set<String> set = list.stream().filter(s -> s.length() == 2).collect(Collectors.toSet());
        System.out.println(set);

    }
}
